import { TypeOrmModuleOptions } from '@nestjs/typeorm';
import { User } from '../modules/user/user.entity';
import { UserBook } from '../modules/book/entities/user-book.entity';
import { Book, BookComment } from '../modules/book/book.entity';
import { Post, PostComment,PostLike } from '../modules/post/post.entity';
import { Notification } from '../modules/notification/notification.entity';
import { Address } from 'src/modules/address/address.entity';

export const databaseConfig: TypeOrmModuleOptions = {
  type: 'mysql',
  host: process.env.DB_HOST || 'localhost',
  port: parseInt(process.env.DB_PORT || '3306', 10),
  username: process.env.DB_USERNAME || 'root',
  password: process.env.DB_PASSWORD || 'mysql*114514',
  database: process.env.DB_DATABASE || 'book_sharing',
  entities: [User, Book, BookComment, Post, PostComment,PostLike, Notification, Notification, UserBook, Address],
  synchronize: process.env.NODE_ENV !== 'production', // 开发环境下自动同步数据库结构
  logging: process.env.NODE_ENV !== 'production',
};
